package vue;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.HttpAuthHandler;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.example.finalprojet.R;

@SuppressLint("SetJavaScriptEnabled")
public class Forum extends Activity {
	
	String pseudo;
	WebView webview;

    @Override
    public void onCreate(Bundle savedInstanceState) {
    	
    	pseudo = getIntent().getStringExtra("pseudo");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_forum);
        
        
     

webview = (WebView)findViewById(R.id.web);

webview.setWebViewClient(new myWebViewClient());

webview.getSettings().setJavaScriptEnabled(true);

webview.loadUrl("http://spartacus.iutc3.unicaen.fr/~projet.echec/phpBB3/");

}

 

@Override

public boolean onKeyDown(int keyCode, KeyEvent event) {

if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {

	//Intent nextScreen = new  Intent (getApplicationContext(), DashBoard.class );
	//nextScreen.putExtra("id",main.get("id").toString() );
	//nextScreen.putExtra("pseudo",pseudo);
	//startActivity (nextScreen);
	this.finish();
	

return true;

}

return super.onKeyDown(keyCode, event);

}

 

private class myWebViewClient extends WebViewClient {

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {


	
view.loadUrl(url);

return true;

}

public void onReceivedHttpAuthRequest(WebView view,
        HttpAuthHandler handler, String host, String realm) {

    handler.proceed("projet.echec", "eepuhohx");

}

}

}